<template>
    <div>
      <!--头部-->
      <div class="front-header">
        <div class="front-header-left">
          <img src="@/assets/img/logo.png" alt="">
          <div class="title">大学生成长成才监测平台</div>
        </div>
        <div class="front-header-center">
          <div class="front-header-nav">
            <el-menu :default-active="$route.path" mode="horizontal" router>
                <el-menu-item index="/teacher/home">首页</el-menu-item>
                <el-menu-item index="/teacher/learnProgress">学习情况</el-menu-item>
                <el-menu-item index="/teacher/StudlyManagement">学习管理</el-menu-item>
                <el-menu-item index="/teacher/counselingstats">咨询统计</el-menu-item>
              <el-menu-item index="/teacher/person">个人中心</el-menu-item>
              <el-menu-item index="/teacher/CommentList1">心理健康论坛</el-menu-item>
            </el-menu>
          </div>
        </div>
        <div class="front-header-right">
          <el-dropdown>
            <div class="front-header-dropdown">
<!--              <img src="../assets/img/logo.png" alt="" />-->
              <div style="margin-left: 10px; color: white">
                <span>{{ user.name }}</span><i class="el-icon-arrow-down" style="margin-left: 5px"></i>
              </div>
            </div>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>
                <div style="text-decoration: none" @click="navTo('/teacher/person')">个人中心</div>
              </el-dropdown-item>
<!--              <el-dropdown-item>-->
<!--                <div style="text-decoration: none" @click="navTo('/teacher/password')">修改密码</div>-->
<!--              </el-dropdown-item>-->
                <el-dropdown-item>
                  <div style="text-decoration: none" @click="logout">退出</div>
                </el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </div>
      <!--主体-->
      <div class="main-body">
        <router-view ref="child" @update:user="updateUser" />
      </div>
    </div>
  
  </template>
  
  <script>
  
  export default {
    name: "Student",
  
    data () {
      return {
        notice: [],
        user: JSON.parse(localStorage.getItem("honey-user") || '{}'),
      }
    },
  
  
    methods: {
      navTo(path) {
        this.$router.push(path);
      },
      updateUser() {
        this.user = JSON.parse(localStorage.getItem('honey-user') || '{}')   // 重新获取下用户的最新信息
      },
      // 退出登录
      logout() {
        localStorage.removeItem("honey-user");
        this.$router.push("/");
      },
      navTo(url) {
        location.href = url
      }
    }
  }
  </script>
  
  <style scoped>
  @import "@/assets/css/student.css";
  
  </style>